<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">
    	<div id="echart" style="width:50%;height:400px;display: inline-block;"></div>
    	<div id="echart2" style="width:500px;height:400px;display: inline-block;"></div>
    </div>
</div>
<script>
$(function(){
	//1
	$.post("/private/fees/feesEchart",{},function(obj){
		if(obj.success&&obj.data!=null){
			var xdata =[];
			var ydata =[];
			for(var i=0;i<obj.data.length;i++){
				xdata.push(obj.data[i].name);
				ydata.push(obj.data[i].money);
			}
			echart(xdata,ydata);
		}
	},"json");
	//2
	$.post("/private/fees/feesEchartTimeUser",{},function(obj){
		if(obj.success&&obj.data!=null){
			var xdata =[];
			var ydata =[];
			for(var i=0;i<obj.data.length;i++){
				xdata.push(obj.data[i].date);
				ydata.push(obj.data[i].count);
			}
			echart2(xdata,ydata);
		}
	},"json");
});
var echart = function(xdata,ydata){
	var myChart = echarts.init(document.getElementById('echart'));
	var option = {
			title: {
			  	text: '规费数据统计',
			},
		    color: ['#3398DB'],
		    tooltip: {
		        trigger: 'axis',
		        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
		            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
		        }
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis: [
		        {
		            type: 'category',
		            data: xdata,
		            axisTick: {
		                alignWithLabel: true
		            }
		        }
		    ],
		    yAxis: [
		        {
		            type: 'value'
		        }
		    ],
		    series: [
		        {
		            name: '金额',
		            type: 'bar',
		            barWidth: '60%',
		            data: ydata
		        }
		    ]
		};
	myChart.setOption(option);
}
var echart2 = function(xdata,ydata){
	var myChart = echarts.init(document.getElementById('echart2'));
	var option = {
		title: {
		  	text: '时间驾驶员统计',
		},
		tooltip: {
	        trigger: 'axis'
	    },
	    xAxis: {
	        type: 'category',
	        data: xdata
	    },
	    yAxis: {
	        type: 'value'
	    },
	    series: [{
	        data: ydata,
	        type: 'line',
	        markPoint: {
                data: [
                    {type: 'max', name: '最大值'},
                    {type: 'min', name: '最小值'}
                ]
            }
	    }]
	};
	myChart.setOption(option);
}
</script>